/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package projetluc;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Calendar;

/**
 *
 * @author Lone_Wolf
 */
public class Facture implements Serializable {

    private int[] date = new int[3];        //yyyy/mm/dd
    private Client client;
    private String numero;
    private double montantCharge;
    private ArrayList<Entree> arEntree;

    public Facture(Client client) {
        this.client = client;
        arEntree = new ArrayList<Entree>();
    }

    public Client getClient() {
        return client;
    }

    public void addEntree(Entree entree) {
        arEntree.add(entree);
    }

    public Entree getEntree(int index) {
        return arEntree.get(index);
    }

    public void removeEntree(Entree entree) {
        arEntree.remove((Entree) entree);
    }
    
    public boolean contientEntree(Entree entree){
        return arEntree.contains(entree);
    }

    public int getNbeEntrees() {
        return arEntree.size();
    }

    public void setNumero(String numero) {
        this.numero = numero;
    }

    public String getNumero() {
        return numero;
    }
    
    public void setCurrentDate(){
        Calendar cal = Calendar.getInstance();
        date[0] = cal.get(cal.YEAR);
        date[1] = cal.get(cal.MONTH) + 1;
        date[2] = cal.get(cal.DATE);
    }
    
    public void setDate(int[] date){
        this.date = date;
    }

    public String getDate_S() {
        String temp = date[0] + "/" + date[1] + "/" + date[2];
        return temp;
    }
    public int[] getDate(){
        return date;
    }

    public void finaliser() {
        for (int i = 0; i < arEntree.size(); i++) {
            arEntree.get(i).setFacturee(true);
        }
    }
    
    public void supprimerEntree() {
        for (int i = 0; i < arEntree.size(); i++) {
            arEntree.get(i).setFacturee(false);
        }
    }

    public double getCoutTotal() {
        double cout = 0;
        for (int i = 0; i < arEntree.size(); i++){
            cout += arEntree.get(i).getCout();
        }

        return cout;
    }
    
    public void setMontantCharge(double montantCharge){
        this.montantCharge = montantCharge;
    }
    
    public double getMontantCharge(){
        return montantCharge;
    }
}
